// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   query_key.java

package include.query;

import include.nseer_db.nseer_db;
import java.sql.ResultSet;

public class query_key
{

	private String dbase;
	private String tableName;
	private String timea;
	private String timeb;
	private String idNumber;
	private String keyword;
	private String fieldName;
	private String fieldName1;
	private String fieldName2;
	private String fieldName3[];
	private String realname;
	private String condition;
	private String queue;
	private String tagq;
	private String sql;
	private String sql1;
	private String sql2;
	private String sql3;
	private String sql4;
	private String sql5;
	private String sql6;
	private String sql7;
	private nseer_db dba;
	private nseer_db dbb;
	private ResultSet rs;
	private ResultSet rs1;
	private ResultSet rs2;
	private ResultSet rs3;
	private ResultSet rs4;
	private ResultSet rs5;
	private ResultSet rs6;
	private ResultSet rs7;
	private double tradeTotal;
	private int intValue;
	private double doubleValue;

	public query_key()
	{
		dbase = "";
		tableName = "";
		timea = "";
		timeb = "";
		idNumber = "";
		keyword = "";
		fieldName = "";
		fieldName1 = "";
		fieldName2 = "";
		fieldName3 = new String[1000];
		realname = "";
		condition = "";
		queue = "";
		tagq = "";
		sql = "";
		sql1 = "";
		sql2 = "";
		sql3 = "";
		sql4 = "";
		sql5 = "";
		sql6 = "";
		sql7 = "";
		rs = null;
		rs1 = null;
		rs2 = null;
		rs3 = null;
		rs4 = null;
		rs5 = null;
		rs6 = null;
		rs7 = null;
		tradeTotal = 0.0D;
		intValue = 0;
		doubleValue = 0.0D;
	}

	public ResultSet queryDB(String dbase, String tName, String uKeyword, String fName3[], String uCondition, String uQueue)
	{
		this.dbase = dbase;
		tableName = tName;
		keyword = uKeyword;
		fieldName3 = fName3;
		condition = uCondition;
		queue = uQueue;
		dba = new nseer_db(dbase);
		try
		{
			String key = "";
			int m = 0;
			for (int i = 0; i < fieldName3.length - 1; i++)
			{
				key = (new StringBuilder(String.valueOf(key))).append(fieldName3[i]).append(" like ").append("'%").append(keyword).append("%'").append(" or ").toString();
				m++;
			}

			key = (new StringBuilder(String.valueOf(key))).append(fieldName3[m]).append(" like ").append("'%").append(keyword).append("%'").toString();
			if (!key.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where (").append(key).append(") and ").append(condition).append(" ").append(queue).toString();
			else
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(condition).append(" ").append(queue).toString();
			rs = dba.executeQuery(sql);
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
		return rs;
	}

	public int intValue()
	{
		try
		{
			intValue = 0;
			dbb = new nseer_db(dbase);
			sql1 = sql;
			rs1 = dbb.executeQuery(sql1);
			if (rs1.last())
				intValue = rs1.getRow();
			dbb.close();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
		return intValue;
	}

	public double sumTotal(String fName)
	{
		fieldName = fName;
		try
		{
			dbb = new nseer_db(dbase);
			sql2 = sql;
			rs2 = dbb.executeQuery(sql2);
			for (tradeTotal = 0.0D; rs2.next(); tradeTotal += rs2.getDouble(fieldName));
			dbb.close();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
		return tradeTotal;
	}

	public void close()
	{
		dba.close();
	}
}
